import request from "../../utils/http/index";
import {MenuForm } from "./types/menu.dto";
import {ApiResponse} from "../../utils/ApiResponse";

//新增菜单
export const addMenu = (data: MenuForm) => {
    return request({
        url: "/menu/createMenu",
        data,
        method: "post",
    });
};

//获取菜单列表
export const getMenuList = () => {
    return request({
        url: "/menu/trees",
        method: "get",
    });
};

// 获取当前用户菜单
export const getCurrentUserMenu = (): Promise<ApiResponse<MenuForm[]>> => {
    return request({
        url: "/menu/current/dynamic",
        method: "get",
    });
}

//删除菜单
export const deleteMenu = (menuId: number | number[]) => {
    return request({
        url: `/menu/deleteMenu/${menuId}`,
        method: "delete",
    });
};

//更新菜单
export const updateMenu = (data: MenuForm) => {
    return request({
        url: `/menu/updateMenu`,
        method: "put",
        data
    });
};





